<%- include ../public/page_header.html %>

        <!-- 引入分页插件 -->

          <script src="/public/admin/js/jqPaginator.js"></script>


          <div class="panel panel-default">
            <div class="panel-heading">
                搜索商品
            </div>
            <div class="panel-body">
                <form role="form" class="form-inline" action="/admin/goods" method="get">
                    <div class="form-group">
                        <label for="keyword">请输入商品名称</label>
                        <input type="text" class="form-control" id="keyword" name="keyword" placeholder="请输入商品名称">
                    </div>
        
                    <div class="form-group">
                        <button type="submit" class="btn btn-default">开始搜索</button>
                    </div>
                </form>
            </div>
        </div>

            <div class="panel panel-default">              
                    <div class="panel-heading">
                        <a href="/admin/goods/add" class="btn btn-primary">增加商品</a>
                    </div>
                    <div class="panel-body">
            <!--
                列表展示
            -->
                    <div class="table-responsive">
                        <table class="table table-bordered">
                            <thead>                                   
                            <tr class="th">
                                <th>商品名称</th>
                                <th>货号</th>
                                <th>价格</th>  
                                <th>点击量</th>
                                <th>上架</th>

                                <th>精品</th>
                                <th>新品</th>
                                <th>热销</th>
                                <th>推荐排序</th>
                                <th>库存</th>                             
                                <th class="text-center">操作</th>
                            </tr>
                            </thead>
                            <tbody>
                                 
                                <%for(var i=0;i<list.length;i++){%>
                                    <tr>
                                        
                                        <td><%=list[i].title%></td>
                                        <td><%=list[i].goods_sn%></td>
                                        <td><%=list[i].shop_price%></td>
                                        <td><%=list[i].click_count%></td>    
                                        
                                        <td  class="text-center">
    
                                                <%if(list[i].status==1){%>
    
                                                        <img src="/public/admin/images/yes.gif" onclick="app.changeStatus(this,'Goods','status','<%=list[i]._id%>')" />
    
                                                <%}else{%>
                                                        <img src="/public/admin/images/no.gif"  onclick="app.changeStatus(this,'Goods','status','<%=list[i]._id%>')" />
                                                <%}%>
    
                                        </td>                                           
                                        
                                        <td  class="text-center">
    
                                            <%if(list[i].is_best==1){%>

                                                    <img src="/public/admin/images/yes.gif" onclick="app.changeStatus(this,'Goods','is_best','<%=list[i]._id%>')" />

                                            <%}else{%>
                                                    <img src="/public/admin/images/no.gif"  onclick="app.changeStatus(this,'Goods','is_best','<%=list[i]._id%>')" />
                                            <%}%>

                                        </td> 
                                        
                                        <td  class="text-center">
    
                                            <%if(list[i].is_news==1){%>

                                                    <img src="/public/admin/images/yes.gif" onclick="app.changeStatus(this,'Goods','is_news','<%=list[i]._id%>')" />

                                            <%}else{%>
                                                    <img src="/public/admin/images/no.gif"  onclick="app.changeStatus(this,'Goods','is_news','<%=list[i]._id%>')" />
                                            <%}%>

                                        </td> 

                                        <td  class="text-center">
    
                                            <%if(list[i].is_hot==1){%>

                                                    <img src="/public/admin/images/yes.gif" onclick="app.changeStatus(this,'Goods','is_hot','<%=list[i]._id%>')" />

                                            <%}else{%>
                                                    <img src="/public/admin/images/no.gif"  onclick="app.changeStatus(this,'Goods','is_hot','<%=list[i]._id%>')" />
                                            <%}%>

                                        </td> 


                                        <td class="text-center"><span onclick="app.editNum(this,'Goods','sort','<%=list[i]._id%>')"><%=list[i].sort%></span></td>


                                        <td class="text-center"><span onclick="app.editNum(this,'Goods','goods_number','<%=list[i]._id%>')"><%=list[i].goods_number%></span></td>
    
    
                                        <td class="text-center"><a href="/admin/goods/edit?id=<%=list[i]._id%>">修改</a>　　<a  class="delete" href="/admin/delete?id=<%=list[i]._id%>&model=Goods">删除</a></td>
                                    </tr>       
                                <%}%>


                            </tbody>
                        </table>

                        <div id="page" class="pagination fr"></div>
                    </div>
                </div>
            </div>


            <script>
               $('#page').jqPaginator({
                    totalPages: <%=totalPages%>,
                    visiblePages: 8,
                    currentPage:  <%=page%>,
                    onPageChange: function (num, type) {
                        console.log('当前第' + num + '页',type);

                        if(type=='change'){

                        location.href="/admin/goods?page="+num;
                        }
                    }
                });
            </script>
</body>
</html>